package encaps.utils;

import encaps.entities.MovieLocalHome;
import encaps.entities.PersonLocalHome;
import encaps.entities.UserLocalHome;
import encaps.logging.LogLocalHome;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

public class EntityUtil {

    public static UserLocalHome getUserHome() throws NamingException {
        Context ctx = new InitialContext();
        UserLocalHome userHome = (UserLocalHome) ctx.lookup("java:comp/env/ejb/User");
        ctx.close();
        return userHome;
    }

    public static MovieLocalHome getMovieHome() throws NamingException {
        Context ctx = new InitialContext();
        MovieLocalHome movieHome = (MovieLocalHome) ctx.lookup("java:comp/env/ejb/Movie");
        ctx.close();
        return movieHome;
    }

    public static PersonLocalHome getPersonHome() throws NamingException {
        Context ctx = new InitialContext();
        PersonLocalHome personHome = (PersonLocalHome) ctx.lookup("java:comp/env/ejb/Person");
        ctx.close();
        return personHome;
    }

    public static LogLocalHome getLogHome() throws NamingException {
        Context ctx = new InitialContext();
        LogLocalHome LogGome = (LogLocalHome) ctx.lookup("java:comp/env/ejb/Log");
        ctx.close();
        return LogGome;
    }
}
